<template>
	<view class="MyPartner bigestBox boxSize_bb">
		
		<view
			class="four flex bc_p15_bs"
			v-for="(item) in bbsAll"
			@tap="gotoEdit(item)"
			@longtap="isDel(item)"
		>
			<image v-if="item.coverList.length > 0" :src="item.coverList && item.coverList.length > 0 ? item.coverList[0] : ''" mode="" style="width: 120rpx;height: 120rpx;">
			</image>
			<view class="four_right flexDeCo">
				<view class="fr_top">{{ item.title | truncate(20) }}</view>
				<view class="fr_bottom flex_jcsb" style="margin-top: 20rpx;">
					<view class="frb_left">
						{{ item.content | truncate(10) }}
					</view>
					<view class="frb_right">
						{{ item.createTime }}
					</view>
				</view>
			</view>
		</view>
		<!-- <view class="flexDeCo four bc_p15_bs" @click="goToPatnerActivies">
			<view class="flex">
				<image src="/static/images/HiltonHotel/hotelImg1.png" mode="" style="width: 120rpx;height: 120rpx;">
				</image>
				<view class="four_right flexDeCo">
					<view class="fr_top">搓麻将，一缺三</view>
					<view class="fr_bottom flex_jcsb">
						<view class="frb_left">
							狗狗的尾巴
						</view>
						<view class="frb_right">
							2025-02-19 17:45:26
						</view>
					</view>
				</view>
			</view>
			<view class="four_img flex" style="margin-top: 30rpx;">
				<image src="/static/images/HiltonHotel/hotelImg1.png" mode="" style="width: 196rpx;height: 196rpx;">
				</image>
				<image src="/static/images/HiltonHotel/hotelImg1.png" mode=""
					style="width: 196rpx;height: 196rpx;margin-left: 20rpx;">
				</image>
				<image src="/static/images/HiltonHotel/hotelImg1.png" mode=""
					style="width: 196rpx;height: 196rpx;margin-left: 20rpx;">
				</image>

			</view>
		</view> -->
		<view class="submit">
			<button type="default" @tap="submit">立即发布</button>
		</view>
	</view>
</template>

<script>
	import { navigateTo } from "@/utils/promise"
import { bbsDelete, mybbsList } from "../../api/bbs";
import { showModal, showToast } from "../../utils/promise";
	export default {
		data() {
			return {
				bbsAll: []
			};
		},
		onShow() {
			this.getMybbsAll()
		},
		filters: {
		    truncate(value, length) {
		      if (!value) return ''
		      if (value.length > length) {
		        return value.substring(0, length) + '...'
		      }
		      return value
		    }
		},
		methods: {
			navigateTo,
			submit() {
				navigateTo({
					url: "/pages/DaziUpload/DaziUpload"
				})
			},
			getMybbsAll() {
				mybbsList().then((res) => {
					const {code, data, msg} = res
					console.log(data)
					if(code === 200) {
						this.bbsAll = data.records
					}
				}).catch((err) => {
					console.log(err)
				})
			},
			goToNewPage(id) {
				// this.$emit("gotoNewPage")
				navigateTo({
					url: `/pages/DaziUpload/DaziUpload?id=${id}`
				})
			},
			isDel(item) {
				showModal({
					title: "删除确认",
					content: `是否确认删除 ${item.title} `,
					showCancel: true,
					cancelText: "否",
					confirmText: "是"
				}).then((res) => {
					if(res.cancel) {
						return
					}
					let params = {
						id: item.id
					}
					// console.log(params)
					bbsDelete(params).then((res) => {
						console.log(res)
						const {code, data, msg} = res
						if(code === 200 && data) {
							showToast({
								title: "删除成功"
							})
							this.getMybbsAll()
							return
						}
						showToast({
							title: "删除失败, 请重试"
						})
					}).catch((err) => {
						// console.log(err)
						showToast({
							title: "删除失败, 请重试"
						})
					})
				})
			},
			gotoEdit(item) {
				navigateTo({
					url: `/pages/DaziUpload/DaziUpload?id=${item.id}`
				})
			},
		}
	}
</script>

<style lang="less" scoped>
	@import "../../static/commonStyleLess/grayBox.less";

	.MyPartner {
		margin-top: 0rpx;
		
		// .head {
		// 	display: flex;
		// 	width: 750rpx;
		// 	// height: 80rpx;
		// 	box-sizing: border-box;
		// 	padding: 20rpx;
		// 	background: #FFF4DB;
		// 	align-items: center;
		
		// 	.head_one {
		// 		width: 40rpx;
		// 		height: 40rpx;
		// 	}
		
		// 	.head_two {
		// 		font-weight: 400;
		// 		font-size: 26rpx;
		// 		letter-spacing: 0px;
		// 		color: #804040;
		// 		margin-left: 10rpx;
		
		
		// 	}
		// }
		
		.four {
			width: 690rpx;
			border-radius: 16rpx;
			// align-items: center;

			.four_left_img {
				width: 120rpx;
				height: 120rpx;
			}

			.four_right {
				margin-left: 20rpx;
				justify-content: space-between;
				flex: 1;

				.fr_top {
					font-weight: 600;
					font-size: 34rpx;
					letter-spacing: -0.82rpx;
					font-size: 26rpx;
				}

				.fr_bottom {
					font-weight: 400;
					font-size: 26rpx;
					letter-spacing: -0.82rpx;
					color: #979797;
					justify-content: space-between;

				}
			}
		}
		.submit {
			background-color: transparent;
			padding: 100rpx 0;
			width: 90%;
			position: relative;
			bottom: 0;
			left: 50%;
			transform: translateX(-50%);
			place-content: center;
			place-items: center;
			z-index: 100;
			button {
				background-color: rgb(15, 76, 151);
				color: white;
				border-radius: 60rpx;
				width: 100%;
				height: 80rpx;
				line-height: 80rpx;
			}
		}
	
		.bc_p15_bs {
			margin: 30rpx;
		}
	}
</style>